package com.huluobo.base.view

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider

/**
 *  Created by LC on 2024/8/7.
 */
abstract class BaseMVVMActivity<VDB : ViewDataBinding, VM : ViewModel> : AppCompatActivity() {
    protected lateinit var dataBinding: VDB
    protected lateinit var viewModel: VM

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        dataBinding = DataBindingUtil.setContentView(this, getLayoutId())
        viewModel = ViewModelProvider(this)[getViewModel()]
        initView()
        initData()
    }

    abstract fun initData()

    abstract fun initView()

    abstract fun getViewModel(): Class<VM>

    abstract fun getLayoutId(): Int
}